package com.alibaba.user.controller;


import com.alibaba.basic.uitl.AjaxResult;
import com.alibaba.user.dto.AccountDto;
import com.alibaba.user.dto.WechatBinderDto;
import com.alibaba.user.dto.WechatDto;
import com.alibaba.user.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

@RestController
@RequestMapping("/login")
public class LoginController {

    @Autowired
    private LoginService loginService;

    /**
     * 登录
     */
    @PostMapping("/account")
    public AjaxResult account(@RequestBody @Valid AccountDto dto){
        return loginService.account(dto);
    }

    /**
     * 扫码登录接口
     */
    @PostMapping("/wechat")
    public AjaxResult wechat(@RequestBody @Valid WechatDto dto){
        return loginService.wechat(dto);
    }

    /**
     * 微信绑定接口
     */
    @PostMapping("/wechat/binder")
    public AjaxResult wechatBinder(@RequestBody @Valid WechatBinderDto dto){
        return loginService.wechatBinder(dto);
    }

}
